package org.lee.normal.delegate;

import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.MethodDelegation;

import java.util.List;

import static net.bytebuddy.matcher.ElementMatchers.named;

/**
 * @author jackielee
 * @version 1.0
 * @description Demo
 * @date 2021/7/28
 **/
class Demo {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        MemoryDatabase loggingDatabase = new ByteBuddy()
                .subclass(MemoryDatabase.class)
                .method(named("load")).intercept(MethodDelegation.to(LoggerInterceptor.class))
                .make()
                .load(Demo.class.getClassLoader())
                .getLoaded()
                .newInstance();
        List<String> res = loggingDatabase.load("good");
        System.out.println(res);
    }
}

